<%@page import="java.awt.peer.SystemTrayPeer"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" import="java.util.*,com.lv.model.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>欢迎登陆到您的主页</title>
<script type="text/javascript" src="/testmybatis/jquery-2.2.4.min.js"></script>
<script type="text/javascript">
	function addScore() {
		$.ajax({
			url : "/testmybatis/scoreController/addScores",
			type : "post",
			data : $("#formId").serialize(),
			dataType : "json",
			success : function(u) {

			}

		});
	}
	function addClasses() {
		$.ajax({
			url : "/testmybatis/classesController/addClasses",
			type : "post",
			data : {
				id : $("#classes_id").val(),
				name : $("#classes_name").val(),

			},
			dataType : "json",
			success : function(u) {

				$("#tips_1").append(
						"科目编号:" + u.class_id + ";科目名称:" + u.class_name);
			}

		});
	}
</script>

</head>

<body>
	<p>用户信息</p>
	<hr />
	<%
		Score[] score = (Score[]) request.getAttribute("score");
		//接受登陆用户的信息
		User u = (User) session.getAttribute("user");
		//接受所有用户的信息
		List<User> use = (List<User>) request.getAttribute("use");
		for (int i = 0; i < use.size(); i++) {
			User ss = use.get(i);
			out.println("<hr/>"+"<br />" + "姓名:" + ss.getUserName() );
			for (int j = 0; j < ss.getScore().size(); j++) {
				Score s_1 = ss.getScore().get(j);
				Classes s_2 = ss.getClasses().get(j);
				out.println("<br />"+"课程:" + s_2.getClass_name() + ";课程ID:" + s_2.getClass_id() + ";课程分数:" + s_1.getScore()
						);

			}

		}

		out.println("<hr/><br/>"+"姓名:" + u.getUserName());
		for (int i = 0; i < score.length; i++) {
			out.println("<br />分数:" + score[i].getScore() + "科目ID:" + score[i].getClass_id() + ";科目名");
		}
	%>

	<hr />
	<br />
	<div id="tips"></div>
	<hr />
	<form id="formId">
		<table>
			<tr>
				<td>科目编号:</td>
				<td><input id="class_id" name="class_id" /></td>
				<td><input id="class_id_1" name="id_1" /></td>
			</tr>
			<tr>
				<td>姓名:</td>
				<td><input id="user_name" name="user" /></td>
				<td><input id="user_name_1" name="name_1" /></td>
			</tr>
			<tr>
				<td>分数:</td>
				<td><input id="user_score" name="score" /></td>
				<td><input id="user_score_1" name="score_1" /></td>
			</tr>
			<tr>
				<td><button type="button" onclick="addScore()">加入新的成绩</button></td>
			</tr>
		</table>
	</form>
	<hr />
	<p>添加课程</p>
	<table>
		<tr>
			<td>科目编号:</td>
			<td><input id="classes_id" /></td>
		</tr>
		<tr>
			<td>姓名:</td>
			<td><input id="classes_name" /></td>
		</tr>

		<tr>
			<td><button onclick="addClasses()">加入新的课程</button></td>
		</tr>
	</table>
	<hr />
	<br>
	<div id="tips_1"></div>
	</br>
	<hr />
</body>
</html>